<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>注册-思多客</title>
    <link href="http://cdn.bootcss.com/normalize/7.0.0/normalize.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/public/css/m/public.css">
    <link rel="stylesheet" href="/public/css/m/login-register.css">
</head>

<body>
    <div class="n-page">
        <div class="new-header flex">
            <!-- <div class="back-box">
                <img src="/public/images/m/back.png" alt="" class="left-back-icon">
            </div> -->
            <span class="header-title flex-child-box">注册</span>
        </div>
        <div class="regist-content">
            <div class="center-logo-box">
                <img src="/public/images/m/logo-h.png" alt="" class="logo-icon">
                <span>传播智慧,&nbsp;传承分享</span>
            </div>
            <div class="login-form">
                <input type="text" placeholder="用户名" class="form-input"  id="J_username">
                <input type="password" placeholder="密码" class="form-input" id="J_pwd">
                <input type="text" placeholder="请输入邀请码" class="form-input" id="J_inviteCode">
                <div class="login-btn" id="J_reg_btn">注册</div>
                <p class="tips-box center">已有账号？ 马上<a href="/m/login.html" class="reg-btn">登录</a></p>
            </div>
            <p class="other-login-type">第三方账号注册</p>
            <div class="gologin-btn">
                <img class="J_oauth_button" src="/public/images/qq-icon.png" alt="" data-type="qq">
                <!-- <img class="J_oauth_button" src="/public/images/wechat-icon.png" alt="" data-type="wx">
                <img class="J_oauth_button" src="/public/images/alipay-icon.png" alt="" data-type="alipay"> -->
            </div>
        </div>
    </div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="/public/js/m/fontResize.js"></script>
<script src="/public/lib/layer/layui.js"></script>
<script src="/public/js/G.js"></script>
<script src="/public/js/user.js"></script>
<script src="/public/js/m/public.js"></script>
<script>
//注册
$(document).on('click', '#J_reg_btn', function() {
    console.log('注册')
    var username = $('#J_username').val().trim();
    var password = $('#J_pwd').val().trim();
    var inviteCode = $('#J_inviteCode').val().trim();
    if (!username) {
        alert('用户名不能为空')
        return;
    }
    if (!password) {
        alert('密码不能为空')
        return;
    }
    var params = {
        username: username,
        secretkey: password,
        inviteCode: inviteCode
    }
    loading.open()
    user.register(params, function() {
        user.login(params, function(data) {
            if (data) {
                var time = 60 * 24 * 1;
                G.setCookie('jwt', data.jwt, time)
                G.setCookie('sdk_user_id', data.user.userId, time)
                G.setCookie('sdk_user_type', data.user.userType, time)
                G.setCookie('sdk_user_avator', data.user.avatorUrl, time)
                setTimeout(function() {
                    loading.close()
                    location.href = '/m/index.html';
                }, 500)
            }
        }, function(err) {
            console.error(err)
            alert(err)
        })
    }, function(err) {
        console.error(err)
        alert(err)
    })
})
</script>

</html>